package com.fit.pages.professor;


import java.util.List;

import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.fit.annotations.AdminAccess;
import com.fit.annotations.AnonymousAccess;
import com.fit.annotations.ProfessorAccess;
import com.fit.annotations.StudentAccess;
import com.fit.dao.homework.HomeworkDAO;
import com.fit.dao.language.LanguageDAO;
import com.fit.dao.professor.ProfessorDAO;
import com.fit.dao.user.UserDAO;
import com.fit.entities.homework.Homework;
import com.fit.entities.language.Language;
import com.fit.entities.professor.Professor;
import com.fit.entities.user.User;
import com.fit.pages.ErrorPage;

@AdminAccess
@AnonymousAccess
@ProfessorAccess
@StudentAccess
public class View {

	@Property
	@Persist
	private Professor professor;
	@Inject
	private ProfessorDAO professorDAO;
	@InjectPage
	private ErrorPage errorPage;

	@Property
	private List<Professor> professors;
	
	void onActivate() {
		professors = professorDAO.findAll();
	}

	Object onActivate(Long id) {
		professor = professorDAO.findByID(id);
		if (professor == null) {
			errorPage.setMessage("Error while trying to view professor! ");
			return errorPage;
		}
		professors = professorDAO.findAll();

		return professors;

	}

}
